<?php

namespace app\index\model;

use think\Model;
use think\Db;

class Question extends Model
{
    public function addQuestion($data)
    {

        $data['uid'] = session('uid');

        $data['ctime'] = time();

        if($data['cid']==1){
            $data['ext'] = json_encode($data['ext']);
        }else{
            unset($data['ext']);
        }

        $this->data($data);

        $res = $this->save();

        User::get(session('uid'))->setDec('kiss',$data['kiss']);

        if($res){
            return $this->qid;
        }else{
            return $res;
        }
    }
}